<template>
  
</template>

<script>
import { URLP, UseCodeToToken } from './../api/api'
export default {
    data:()=>({

    }),
    created:function(){
       var oauth = URLP("oauth")
       var code = URLP("code")
       if(oauth == "wechat"){
           UseCodeToToken(code)
           .then((resp)=>{
               var res = resp.data
               if (res.code == 1){
                   this.$cookies.set("authtoken", res.data)
                   this.$router.push("/user/center")
                   return
               }
               this.$store.commit('setAlert',{icon:'close',text:res.msg,show:true})
           })
           .catch((err)=>{
               this.$store.commit('setAlert',{icon:'close',text:err,show:true})
           })
       }
    }
    
}
</script>

<style>

</style>